package Koneksi;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class stok {
    private String nama, kode, jenis, jumlah; 

    public String getNama() {
        return nama;
    }

    public void setNama(String nama) {
        this.nama = nama;
    }

    public String getKode() {
        return kode;
    }

    public void setKode(String kode) {
        this.kode = kode;
    }

    public String getJenis() {
        return jenis;
    }

    public void setJenis(String jenis) {
        this.jenis = jenis;
    }

    public String getJumlah() {
        return jumlah;
    }

    public void setJumlah(String jumlah) {
        this.jumlah = jumlah;
    }
    
    public List tampil() throws SQLException {
        List stok = new ArrayList(); 
        Connection con = Koneksi.open(); 
        String ret = "SELECT * FROM BARANG_O";
        Statement st = con.createStatement(); 
        ResultSet rs = st.executeQuery(ret);
        while(rs.next()){
            stok s = new stok(); 
            s.setNama(rs.getString("nama"));
            s.setKode(rs.getString("kode"));
            s.setJenis(rs.getString("jenis"));
            s.setJumlah(rs.getString("jumlah"));
            stok.add(s);
        }
        con.commit();
        return stok; 
    }
}
